#!/bin/bash

if [ ! -f ffmpeg.h ]; then
    echo "Run this from the root of the source directory."
    exit
fi

{

./configure \
    --prefix=/usr/local \
    --mandir=/usr/local/share/man \
    --extra-cflags="-O3 -march=native -mtune=native -pthread -I/opt/local/include" \
    --extra-cxxflags="-O3 -march=native -mtune=native -pthread -I/opt/local/include" \
    --extra-ldflags="-L/opt/local/lib" \
    --arch=x86_64 \
    --cpu=x86_64 \
    --cc=/usr/local/bin/clang \
    --cxx=/usr/local/bin/clang++ \
    --enable-avfilter \
    --enable-gpl \
    --enable-libfaac \
    --enable-libfreetype \
    --enable-libmodplug \
    --enable-libmp3lame \
    --enable-libopenjpeg \
    --enable-libopus \
    --enable-libschroedinger \
    --enable-libspeex \
    --enable-libtheora \
    --enable-libvorbis \
    --enable-libvpx \
    --enable-libx264 \
    --enable-libxvid \
    --enable-nonfree \
    --enable-postproc \
    --enable-pthreads \
    --enable-shared \
    --enable-swscale \
    --enable-version3

} && {

make clean
make -j4 && make install

}
